/*
 * @Descripttion: Lutongli代码
 * @version: 1.0.0
 * @Author: LutongLi
 * @Date: 2025-05-28 08:02:41
 * @LastEditTime: 2025-06-05 00:59:31
 */
package impl

import (
	"context"

	"github.com/infraboard/mcube/logger"

	"gitee.com/king_max/restful-api-demo/apps/host"
)

//以下代码主要是去实现上级host.go文件中的service接口
//业务处理层(controler层)
func (i *HostServiceImpl) CreateHost(ctx context.Context,ins *host.Host)(*host.Host,error){
	//直接打印日志
	i.l.Named("Create函数").Debug("create host success")
	i.l.Info("create host")
	//带format的日志打印，fmt.Sprintf()
	i.l.Debugf("create host %s",ins.Name)
	//携带额外的meta数据 
	i.l.With(logger.NewAny("request-id","req01")).Debug("create host with meta kv")
	
	//业务数据验证
	if err := ins.Validate();err != nil{
		return nil,err
	}
	//默认值的填充
	ins.InjectDefault()

	//由dao模块负责把对象host存入数据库
	if err :=i.save(ctx,ins);err!=nil{
			return nil,err
	}
	return ins,nil
}
func (i *HostServiceImpl) QueryHost(ctx context.Context,req *host.QueryHostRequest) (
	*host.HostSet,error){
	return nil,nil
}
func (i *HostServiceImpl) DescribeHost(ctx context.Context,req *host.QueryHostRequest) (
	*host.Host,error){
	return nil,nil
}
func (i *HostServiceImpl) UpdateHost(ctx context.Context,req *host.UpdateHostRequest)(*host.Host,error){
	return nil,nil
}
func (i *HostServiceImpl) DeleteHost(ctx context.Context,req *host.DeleteHostREquest)(*host.Host,error){
	return nil,nil
}